<?php

namespace app\common\validate\Business;

use think\Validate;

class Business extends Validate
{
    /**
         * 定义验证规则
         * 格式：'字段名'	=>	['规则1','规则2'...]
         *
         * @var array
         */
    	protected $rule = [
            'mobile' => 'require|regex:^1[3-9]\d{9}$',
            'nickname' => 'require|length:2,20',
            'password' => 'require|length:6,20',
            'gender' => 'number|in:0,1,2',
            'sourceid' => 'number',
            'deal' => 'number|in:0,1',
            'money' => 'number|>=:0',
            'email' => 'email',
            'auth' => 'number|in:0,1',
            'parentid' => 'number',
        ];

        /**
         * 定义错误信息
         * 格式：'字段名.规则名'	=>	'错误信息'
         *
         * @var array
         */
        protected $message = [
            'mobile.require' => '手机号必填',
            'mobile.regex' => '手机号格式不正确',
            'nickname.require' => '昵称必填',
            'nickname.length' => '昵称长度必须要在4到20',
            'password.require'  => '密码必填',
            'password.length'  => '密码长度必须要在6到20',
            'gender.number'      => '性别状态的类型有误',
            'gender.in'      => '性别状态的值有误',
            'sourceid.number' => '注册来源有误',
            'deal.number'      => '成交状态的类型有误',
            'deal.in'      => '成交状态的值有误',
            'money.number'      => '余额必须是数字类型',
            'money.>='      => '余额必须大于等于0元',
            'email.email' => '邮箱格式错误',
            'auth.number'      => '认证状态的类型有误',
            'auth.in'      => '认证状态的值有误',
            'parentid.number' => '推荐人有误' 
        ];

        /**
         * 验证场景定义
         * 格式：'场景名称'	=>	['字段1','字段2'...]
         *
         * @var array
         */
        protected $scene = [
            'noMobile'=>['nickname','password','gender','email']
        ];
}
